<?php
/**
 * @param ParamSirtBasis $ParamSirtBasis
 */
class ParamSirtBasesController extends AppController {

	var $name = 'ParamSirtBases';
	var $helpers = array('Js');

	function index() {
		$this->ParamSirtBasis->recursive = 0;
    //$this->ParamSirtBasis->recursive = 2;
		$this->set('paramSirtBases', $this->paginate());
	}

	function view($id = null) {
    
		if (!$id) {
			$this->Session->setFlash(__('Invalid param sirt basis', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('paramSirtBasis', $this->ParamSirtBasis->read(null, $id));
	}

  /**
   * 
   */
	function add() {
    
		if (!empty($this->data)) {
			$this->ParamSirtBasis->create();
			if ($this->ParamSirtBasis->save($this->data)) {
				$this->Session->setFlash(__('The param sirt basis has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The param sirt basis could not be saved. Please, try again.', true));
			}
		}

    
		$sirtTypes = $this->ParamSirtBasis->SirtType->find('list');
		$sirtSubsetModeXes = $this->ParamSirtBasis->SirtSubsetModeX->find('list');
		$sirtSubsetModeYs = $this->ParamSirtBasis->SirtSubsetModeY->find('list');
		$this->set(compact('sirtTypes', 'sirtSubsetModeXes', 'sirtSubsetModeYs'));
	}

  
	function edit($id = null) {
    
    // If bad id
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid param sirt basis', true));
			$this->redirect(array('action' => 'index'));
		}
    // If ready to submit data
		if (!empty($this->data)) {
			if ($this->ParamSirtBasis->save($this->data)) {
				$this->Session->setFlash(__('The param sirt basis has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The param sirt basis could not be saved. Please, try again.', true));
			}
		}
    
    // If new edit screen
		if (empty($this->data)) {
			$this->data = $this->ParamSirtBasis->read(null, $id);
		}
    
		$sirtTypes = $this->ParamSirtBasis->SirtType->find('list');
		$sirtSubsetModeXes = $this->ParamSirtBasis->SirtSubsetModeX->find('list');
		$sirtSubsetModeYs = $this->ParamSirtBasis->SirtSubsetModeY->find('list');
		$this->set(compact('sirtTypes', 'sirtSubsetModeXes', 'sirtSubsetModeYs'));
	} //////////////// end edit() //////////////////////

  
	function delete($id = null) {
    
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for param sirt basis', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->ParamSirtBasis->delete($id)) {
			$this->Session->setFlash(__('Param sirt basis deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Param sirt basis was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
} ///////////////////////// end class ////////////////////////////////
